package day1;

import com.example.spring.day1.dao.UserDaoMysqlImpl;
import com.example.spring.day1.dao.UserDaoOracleImpl;
import com.example.spring.day1.service.UserService;
import com.example.spring.day1.service.UserServiceImpl;

public class Mytest {
    public static void main(String[] args) {

        // user -> Service层 -> Dao层
        // 用户不直与Dao层接触
        // 通过Service层来进行调用Dao层
        UserService userService = new UserServiceImpl();
        userService.getUser();

        System.out.println("==========");


        // ===============
        // 现在将选择权交给用户，看用户选择那种方式
        // 将权力交给用户


        UserService userService2 = new UserServiceImpl();
        ((UserServiceImpl) userService).setUserDao(new UserDaoMysqlImpl());
        userService2.getUser();
        System.out.println("==========");
        ((UserServiceImpl) userService).setUserDao(new UserDaoOracleImpl());
        userService2.getUser();
    }
}
